package com.foldingleaf.web.controller.collectors;


import com.foldingleaf.collections.service.ISysCollectionService;
import com.foldingleaf.common.annotation.Log;
import com.foldingleaf.common.core.controller.BaseController;
import com.foldingleaf.common.core.domain.Result;
import com.foldingleaf.common.core.domain.entity.SysUser;
import com.foldingleaf.common.core.page.TableDataInfo;
import com.foldingleaf.common.enums.BusinessType;
import com.foldingleaf.common.utils.poi.ExcelUtil;
import com.foldingleaf.show.domain.SysCollection;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 藏品详情Controller
 * 
 * @author ajian
 * @date 2022-06-04
 */
@Api(value = "/collections/collections", tags = {"藏品详情Controller"})
@RestController
@RequestMapping("/collections/collections")
public class SysCollectionController extends BaseController
{
    @Autowired
    private ISysCollectionService sysCollectionService;

    /**
     * 查询藏品详情列表
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "SysCollection", name = "sysCollection", value = "")
    })
    @ApiOperation(value = "查询藏品详情列表", notes = "查询藏品详情列表", httpMethod = "GET")

    @GetMapping("/list")
    public TableDataInfo list(SysCollection sysCollection)
    {
        startPage();
        List<SysCollection> list = sysCollectionService.selectSysCollectionList(sysCollection);

        return getDataTable(list);
    }

    /**
     * 查询用户藏品分组
     */
    public Result listGroup(SysCollection sysCollection)
    {

        sysCollection.setCollectionShowId(107L);
        List<SysCollection> list1 = sysCollectionService.selectSysCollectionList(sysCollection);
        if (list1.size() > 0) {

        }
        sysCollection.setCollectionShowId(110L);
        List<SysCollection> sysCollections = sysCollectionService.selectSysCollectionList(sysCollection);

        sysCollection.setCollectionShowId(121L);
        List<SysCollection> sysCollections121 = sysCollectionService.selectSysCollectionList(sysCollection);
        sysCollection.setCollectionShowId(124L);
        List<SysCollection> sysCollections123 = sysCollectionService.selectSysCollectionList(sysCollection);
        sysCollection.setCollectionShowId(125L);
        List<SysCollection> sysCollection4 = sysCollectionService.selectSysCollectionList(sysCollection);

        return success();
    }

    /**
     * 导出藏品详情列表
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "HttpServletResponse", name = "response", value = ""),
            @ApiImplicitParam(paramType = "query", dataType = "SysCollection", name = "sysCollection", value = "")
    })
    @ApiOperation(value = "导出藏品详情列表", notes = "导出藏品详情列表", httpMethod = "POST")
    @PreAuthorize("@ss.hasPermi('collections:collections:export')")
    @Log(title = "藏品详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysCollection sysCollection)
    {
        List<SysCollection> list = sysCollectionService.selectSysCollectionList(sysCollection);
        ExcelUtil<SysCollection> util = new ExcelUtil<SysCollection>(SysCollection.class);
        util.exportExcel(response, list, "藏品详情数据");
    }

    /**
     * 获取藏品详情详细信息
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "long", name = "collectionId", value = "")
    })
    @ApiOperation(value = "获取藏品详情详细信息", notes = "获取藏品详情详细信息", httpMethod = "GET")

    @GetMapping(value = "/{collectionId}")
    public Result getInfo(@PathVariable("collectionId") Long collectionId)
    {
        return Result.success(sysCollectionService.selectSysCollectionByCollectionId(collectionId));
    }

    /**
     * 新增藏品详情
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "SysCollection", name = "sysCollection", value = "")
    })
    @ApiOperation(value = "新增藏品详情", notes = "新增藏品详情", httpMethod = "POST")
    @PreAuthorize("@ss.hasPermi('collections:collections:add')")
    @Log(title = "藏品详情", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody SysCollection sysCollection)
    {
        return toAjax(sysCollectionService.insertSysCollection(sysCollection));
    }

    /**
     * 修改藏品详情
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "SysCollection", name = "sysCollection", value = "")
    })
    @ApiOperation(value = "修改藏品详情", notes = "修改藏品详情", httpMethod = "PUT")

    @Log(title = "藏品详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody SysCollection sysCollection)
    {
        return toAjax(sysCollectionService.updateSysCollection(sysCollection));
    }

    /**
     * 删除藏品详情
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "Long[]", name = "collectionIds", value = "")
    })
    @ApiOperation(value = "删除藏品详情", notes = "删除藏品详情", httpMethod = "DELETE")
    @PreAuthorize("@ss.hasPermi('collections:collections:remove')")
    @Log(title = "藏品详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{collectionIds}")
    public Result remove(@PathVariable Long[] collectionIds)
    {
        return toAjax(sysCollectionService.deleteSysCollectionByCollectionIds(collectionIds));
    }
}
